package com.xm.xmds1705083.service.util;


import java.sql.Connection;
import java.sql.DriverManager;


public class jdbcutil {
	public  static final String DBURL="com.mysql.jdbc.Driver";
	public  static final String jdbc="jdbc:mysql://116.62.19.114:3306/huibotc?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false&allowMultiQueries=true";  
	public  static final String USERRNAME="server";
	public  static final String PASSWORD="YNfSYceCgvYjiYdY";
   
    public static Connection getConection(){
        Connection conn=null;
        try{
            Class.forName(DBURL);
        conn=DriverManager.getConnection(jdbc, USERRNAME, PASSWORD);
        }
        catch (Exception e) {
                e.printStackTrace();
            }
         return conn;
       }
    public static void close(Connection conn) {
          try {
              if (conn != null)
                   conn.close();
             } catch (Exception e) {
               e.printStackTrace();
             }
         }

    public static int get_crc16(byte[] p,int n)
    {
       int crc=0;
       int temp = 0xffff;
       int i,j;
        for(i=0;i<n;i++)
        {
            temp^=p[i];
            for(j=0;j<8;j++)
            {
                if((temp&0x0001)!=0)
                {
                    temp>>=1;
                    temp^=0xA001;
                }
                else temp>>=1;
            }
        }
        crc = temp & 0xFFFF;
        return crc;


}

}
